package com.chenfan.ccp.plug.rpc.service.impl;

import com.chenfan.ccp.util.start.ApplicationContextUtil;
import com.chenfan.ccp.util.tool.HttpUtil;
import com.chenfan.ccp.plug.rpc.service.CodeGenerateService;

import java.util.HashMap;
import java.util.Map;

/**
 * @author K
 * @date 2021/1/23
 */
public class DefaultCodeGenerateServiceImpl implements CodeGenerateService {

    public static final String GENERATE_CODE_URL = "http://localhost:8080/code/generate";

    @Override
    public String generate(String receiptType, String... prefix) {
        Map<String, Object> param = new HashMap<>(3);
        param.put("projectName", ApplicationContextUtil.getServiceName());
        param.put("receiptType", receiptType);
        if (prefix != null) {
            param.put("prefix", String.join("", prefix));
        }
        return HttpUtil.get(GENERATE_CODE_URL, param);
    }
}
